<template>
    <van-nav-bar
      left-text="旅途"
      left-arrow
      @click-left="onClickLeft"
    >
      <template #title>
        <van-tabs v-model:active="active" type="card" @click-tab="onClickTab">
          <van-tab title="我的收藏"></van-tab>
          <van-tab title="浏览历史"></van-tab>
        </van-tabs>
      </template>
    </van-nav-bar>
  <div class="favor" ref="favorRef">
    <favor-content></favor-content>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import useScroll from '@/hooks/useScroll';
import { useRouter } from "vue-router"
import useFavorStore from '@/stores/modules/favor';
import favorContent from "@/views/favor/cpns/favor-content.vue"
const router = useRouter()
const onClickLeft = () => {
  router.push('/home')
}

const favorRef = ref()
useScroll(favorRef)

const active = ref(0)
const store = useFavorStore()
store.fetchFavorlistData()

const onClickTab = ({name})=>{
  if(name){
    // 历史
    store.fetchFavorHistorylistData()
  }else{
    // 收藏
    store.fetchFavorlistData()
  }
}
</script>

<style lang="less" scoped>

.favor {
  height: calc(100vh - 96px);
  overflow-y: auto;
}

</style>
